import React from 'react'
import PropTypes from "prop-types"
import { routerRedux } from "dva/router"
import { connect } from "dva"
import { Modal, Form, Input } from "antd"

const FormItem = Form.Item;
const { TextArea } = Input;
const formItemLayout = {
    labelCol:{ span:7 },
    wrapperCol:{ span:15 }
}
const ApplicationModal = ({
    form:{ validateFields, getFieldsValue, getFieldDecorator },
    currentItem,
    onOk,
    onCancel,
    ...modalProps,
}) => {
    const { documentYear,notarialMatters,id,contactWay,reason } = currentItem
    const handelSubmit = e =>{
        validateFields((err,values) =>{
            if(!err){
                const params = {
                    status:1,
                    id:id,
                    auditOpinion:values.auditOpinion || ""
                }
                onOk(params)
            }
        })
    }
    const handelSubmit1 = e => {
        validateFields((err,values) =>{
            if(!err){
                const params = {
                    status:2,
                    id:id,
                    auditOpinion:values.auditOpinion || ""
                }
                onOk(params)
            }
        })
    }
    const props = {
        onOk:handelSubmit,
        onCancel:handelSubmit1,
        ...modalProps
    }
    return(
        <Modal {...props}>
            <Form>
                <FormItem {...formItemLayout} label="档案年度">
                    {getFieldDecorator("documentYear",{
                        initialValue:documentYear
                    })(
                        <Input disabled />
                    )}
                </FormItem> 
                <FormItem {...formItemLayout} label="公证事项">
                    {getFieldDecorator("notarialMatters",{
                        initialValue:notarialMatters
                    })(
                        <Input disabled />
                    )}
                </FormItem> 
                <FormItem {...formItemLayout} label="联系方式">
                    {getFieldDecorator("contactWay",{
                        initialValue:contactWay
                    })(
                        <Input disabled/>
                    )}
                </FormItem> 
                <FormItem {...formItemLayout} label="申请原因">
                    {getFieldDecorator("reason",{
                        initialValue:reason
                    })(
                        <TextArea rows={4} disabled/>
                    )}
                </FormItem>
                <FormItem {...formItemLayout} label="审核意见">
                    {getFieldDecorator("auditOpinion",{
                        rules:[
                            {
                                required:true,
                                message:"请填写审核意见"
                            }
                        ]
                    })(
                        <TextArea rows={6}/>
                    )}
                </FormItem>
            </Form>
        </Modal>
    )
}



export default Form.create()(ApplicationModal)